const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
const root = process.cwd()
module.exports = {
  description: 'Create vue view',
  prompts: [
    {
      type: 'input',
      name: 'path',
      message: '请输入路径（Please enter a path）',
      default: 'views'
    },
    {
      type: 'input',
      name: 'name',
      message: '请输入模块名称（Please enter module name）'
    },
  ],
  actions: (data) => {
    const { name, path, tableJsonPath } = data
    const upperFirstName = toUpperCase(name)
    const actions = []
    if (name) {
      actions.push(
        {
          type: 'add',
          path: `./src/${path}/index.vue`,
          templateFile: './plop/view/view.hbs',
          data: {
            name,
            upperFirstName
          }
        },
        {
          type: 'add',
          path: `./src/${path}/component/Write.vue`,
          templateFile: './plop/view/write.hbs',
          data: {
            name,
            upperFirstName
          }
        },
        // {
        //   type: 'add',
        //   path: `./src/${path}/component/Add.vue`,
        //   templateFile: './plop/view/form.hbs',
        //   data: {
        //     name,
        //     upperFirstName
        //   }
        // },
        // {
        //   type: 'add',
        //   path: `./src/${path}/component/Modify.vue`,
        //   templateFile: './plop/view/form.hbs',
        //   data: {
        //     name,
        //     upperFirstName
        //   }
        // },
        // {
        //   type: 'add',
        //   path: `./src/${path}/component/Detail.vue`,
        //   templateFile: './plop/view/detail.hbs',
        //   data: {
        //     name,
        //     upperFirstName
        //   }
        // }
      )
    }

    return actions
  }
}
